package com.cedifie.lendapp.ui.user.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.cedifie.lendapp.R
import com.cedifie.lib_baseadapter.CEDRecyclerViewAdapter
import com.cedifie.lib_baseadapter.CEDViewHolderHelper
import com.lib.base.utils.ImageUtil
import org.json.JSONObject

/**
 * Cedifie
 * @Author wwdeng
 * @CreateTime: 2024/6/17 13:45
 * @Annotation：意见反馈 - 图片列表
 */
class CedUserFeedbackImageAdapter(recyclerView: RecyclerView?): CEDRecyclerViewAdapter<JSONObject>(recyclerView,R.layout.item_feedback_image) {

    override fun setItemChildListener(helper: CEDViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.ivDelete) //删除
        helper.setItemChildClickListener(R.id.ivImage)//选择
    }

    override fun fillData(helper: CEDViewHolderHelper, position: Int, model: JSONObject) {
        val ivImage = helper.getImageView(R.id.ivImage)
        val ivDelete = helper.getImageView(R.id.ivDelete)

        //是否是默认图片
        val isDefault = model.optBoolean("isDefault",true)
        if (isDefault){
            ivImage.setImageResource(R.mipmap.icon_user_feedback_upload)
            ivDelete.visibility = View.INVISIBLE
        } else {
            ImageUtil.instance?.loadImageUrl(mContext,ivImage,model.optString("imgPath"))
            ivDelete.visibility = View.VISIBLE
        }
    }
}